package com.twang.stock.task;

import com.alibaba.fastjson.JSONObject;
import com.twang.stock.dto.StockMinutesMessage;
import com.twang.stock.rocketMq.RocketMQProducer;
import com.twang.stock.service.jinyan.HolidayService;

import com.twang.stock.task.old.BaseTask;
import com.twang.stock.utils.date.DateUtils;
import com.twang.stock.utils.date.HolidayCopy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 */
@Slf4j
@Service
public class KaiPanLaBanKuaiTask extends BaseTask {
    @Autowired
    private RocketMQProducer rocketMQProducer;

    @Autowired
    private HolidayService holidayService;


//    @Scheduled(cron = "0 0/5 9,10,11,12,13,14,15 * * ?")
    public void excute() throws InterruptedException {
        if (!holidayService.isWorkDay(HolidayCopy.getRealToday())) {
            log.info(">>>>>>>>>>>> 开盘啦资金净额  message={}", HolidayCopy.getHHmmss().substring(8, 12));
            return;
        }
        if (DateUtils.JudgeTime("00:09:25", "11:31:00") || DateUtils.JudgeTime("12:59:00", "15:01:00")) {
            开盘啦板块资金净额();
        }
    }

    public void 开盘啦板块资金净额() throws InterruptedException {
        StockMinutesMessage message = new StockMinutesMessage();
        message.setMinutes(HolidayCopy.getHHmmss().substring(8, 12));
        message.setDate(HolidayCopy.getRealToday());
        message.setType(StockMinutesMessage.TYPE_BAN_KUAI_JIN_E);
        log.info(">>>>>>>>>>>> 开盘啦板块资金净额  message={}", JSONObject.toJSONString(message));
        Thread.sleep(60000);//等一分钟触发 抓到最新的数据
        rocketMQProducer.sendOneWay(JSONObject.toJSONString(message));
    }

}
